package com.ruoyi.web.controller.environment;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.environment.domain.EnvProReport;
import com.ruoyi.environment.service.IEnvProReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 环评和批复Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/environment/report")
public class EnvProReportController extends BaseController
{
    @Autowired
    private IEnvProReportService envProReportService;

    /**
     * 查询环评和批复列表
     */
    @PreAuthorize("@ss.hasPermi('environment:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnvProReport envProReport)
    {
        startPage();
        List<EnvProReport> list = envProReportService.selectEnvProReportList(envProReport);
        return getDataTable(list);
    }

    /**
     * 导出环评和批复列表
     */
    @PreAuthorize("@ss.hasPermi('environment:report:export')")
    @Log(title = "环评和批复", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EnvProReport envProReport)
    {
        List<EnvProReport> list = envProReportService.selectEnvProReportList(envProReport);
        ExcelUtil<EnvProReport> util = new ExcelUtil<EnvProReport>(EnvProReport.class);
        return util.exportExcel(list, "环评和批复数据");
    }

    /**
     * 获取环评和批复详细信息
     */
    @PreAuthorize("@ss.hasPermi('environment:report:query')")
    @GetMapping(value = "/{eprId}")
    public AjaxResult getInfo(@PathVariable("eprId") Long eprId)
    {
        return AjaxResult.success(envProReportService.selectEnvProReportById(eprId));
    }

    /**
     * 新增环评和批复
     */
    @PreAuthorize("@ss.hasPermi('environment:report:add')")
    @Log(title = "环评和批复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnvProReport envProReport)
    {
        return toAjax(envProReportService.insertEnvProReport(envProReport));
    }

    /**
     * 修改环评和批复
     */
    @PreAuthorize("@ss.hasPermi('environment:report:edit')")
    @Log(title = "环评和批复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnvProReport envProReport)
    {
        return toAjax(envProReportService.updateEnvProReport(envProReport));
    }

    /**
     * 删除环评和批复
     */
    @PreAuthorize("@ss.hasPermi('environment:report:remove')")
    @Log(title = "环评和批复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eprIds}")
    public AjaxResult remove(@PathVariable Long[] eprIds)
    {
        return toAjax(envProReportService.deleteEnvProReportByIds(eprIds));
    }
}
